NA
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
# Libraries needed to plot absorbance data
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.2 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ ggplot2 3.4.2 ✔ tibble 3.2.1
## ✔ lubridate 1.9.2 ✔ tidyr 1.3.0
## ✔ purrr 1.0.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(ggplot2)
library(ggpubr)
library(zoo)
##
## Attaching package: 'zoo'
##
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
library(scico)
library(plotly)
##
## Attaching package: 'plotly'
##
## The following object is masked from 'package:ggplot2':
##
## last_plot
##
## The following object is masked from 'package:stats':
##
## filter
##
## The following object is masked from 'package:graphics':
##
## layout
# Data
aps.master <- readRDS(file="Data/APSmaster.rds")
aps.master$loc <- as.factor(aps.master$loc)
abs350_t <- readRDS(file="Data/abs350_t.rds")
colores <- scico(7,palette="romaO",begin = 0.1,
end = 0.9) #Color assignment
# Plotting
v <-
aps.master %>%
mutate(loc = fct_relevel(loc,
"FOR","SNO", "GLO","GRA","PLA","SKY","MUS")) %>%
ggplot(aes(x=loc,y=sloperatio)) +geom_jitter(aes(color=loc),width=0.1,alpha=0.5) + theme_classic2(base_size=9) + stat_boxplot(outlier.shape=NA,fill=NA) +
labs(x="Sampling location",y="Slope ratio",color="Location")+
scale_color_scico_d(palette="romaO",begin = 0.1,
end = 0.9)+
theme(axis.text.x=element_text(angle=60, hjust=1),legend.position="none")
a <-
abs350_t %>% group_by(loc) %>% filter(loc %in% c("FOR","SNO", "GLO","GRA","PLA","SKY","MUS")) %>%
summarise_all(median,na.rm=TRUE) %>% mutate(loc = fct_relevel(loc,
"FOR","SNO", "GLO","GRA","PLA","SKY","MUS")) %>%
gather("param","value",-loc) %>%
ggplot(aes(x=as.numeric(param),y=as.numeric(value),color=loc)) +
geom_smooth(se=FALSE,na.rm=TRUE,span=0.1,alpha=0.25,linewidth=0.5) +
coord_cartesian(xlim = c(200,500),
ylim = c(0,40)) + theme_classic2(base_size = 9) +
labs(x="Wavelength (nm)",y="Absorption coefficient [m^-1]",color="Location")+
scale_color_scico_d(palette="romaO",begin = 0.1,
end = 0.9) + theme(legend.position = c(0.9, 0.55),
legend.title=element_text(size=8),
legend.text=element_text(size=7),
#legend.background = element_rect(fill = "white", color = "black")
) + scale_y_continuous(trans='sqrt')
subplot(a,v,nrows=2) #alternative just for markdown
## Warning in self$trans$transform(x): NaNs produced
## Warning: Transformation introduced infinite values in continuous y-axis
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## Warning: Removed 2 rows containing non-finite values (`stat_boxplot()`).
#a/v + plot_annotation(tag_levels = 'A')
#ggsave(filename="Endres_Fig4.tiff",height=160*1.3,width=80*1.3,units='mm',dpi=600)
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.